//英雄机

import java.awt.image.BufferedImage;

public class HeroPlane extends Flyer implements Shoot{

    //属性
    private static HeroPlane plane = null;


    //构造器

    private HeroPlane() {
        setWidth(97);
        setHight(124);
        setBulletnum(1);
        setCreatebulletspeed(StaticNumber.HERO_ATTACK_SPEED);
        setBoold(StaticNumber.HEROBOOLD);
        setAttack(1);
        System.out.println("创建了一个英雄机");
    }



    //方法

    //懒汉模式
    public static HeroPlane getHeroplane(){
        if (PlayPanel.getGamemode()!=1&&plane==null){
            plane = new HeroPlane();
        }
        return plane;
    }

    //英雄机阵亡，取消实例化，方便下一局重新创建新的实例
    public static void Destory(){
        plane = null;
        System.out.println("英雄机阵亡");
    }



    @Override
    void Move() {

    }

    int i = 1;
    @Override
    BufferedImage getImage() {
//        if (getBoold()>0){
//            return heroplaneimg[PlayPanel.getTime()/100%2];
//        }else if (PlayPanel.getTime()%300==0){
//            i++;
//        }
//        if (i>5) {
//            PlayPanel.clear();
//            return null;
//        }
//        return heroplaneimg[i];
        return Game.heroimg[PlayPanel.getTime()/100%2];
    }

    @Override
    public void creatBullet() {
        if (getBulletnum() == 1&&getBoold()>0 &&PlayPanel.getGamemode() == 1){
            if (PlayPanel.getTime()%getCreatebulletspeed() == 0){
                PlayPanel.getBullets().add(new NormalBullet(getX()+getWidth()/2,getY(),getAttack(),false));
            }
        }else if (getBulletnum() == 2&&getBoold()>0&&PlayPanel.getGamemode() == 1){
            if (PlayPanel.getTime()%getCreatebulletspeed() == 0){
                PlayPanel.getBullets().add(new NormalBullet(getX()+getWidth()/4,getY(),getAttack(),false));
                PlayPanel.getBullets().add(new NormalBullet(getX()+3*getWidth()/4,getY(),getAttack(),false));
            }
        }else if (getBulletnum() == 3&&getBoold()>0&&PlayPanel.getGamemode() == 1){
            if (PlayPanel.getTime()%getCreatebulletspeed() == 0){
                PlayPanel.getBullets().add(new NormalBullet(getX()+getWidth()/2,getY()-30,getAttack(),false));
                PlayPanel.getBullets().add(new NormalBullet(getX()+getWidth()/4,getY(),getAttack(),false));
                PlayPanel.getBullets().add(new NormalBullet(getX()+3*getWidth()/4,getY(),getAttack(),false));
            }

        }

    }
}
